package list;

public class List1 {

    public static void main(String[] args) {
        Node head = new Node(7);
        head.next = new Node(3);
        head.next.next= new Node(8);
        head.next.next.next= new Node(5);
        head.next.next.next.next= new Node(6);

        Node n = head;//从头部节点开始访问
        while (n != null){//只要引用了节点就继续访问，null是最后一个
            System.out.println(n.value);//输出
            n = n.next;//获取下一个节点
        }
    }


    static class Node{
        private int value;
        private Node prev;
        private Node next;
        public Node(int value){
            this.value=value;
        }
    }
}
